import request from '@/utils/request'

export const attributePolicyApi = {
  // 创建属性策略
  createAttributePolicy: (policy) => {
    return request.post('/api/attribute-policies', policy)
  },

  // 获取属性策略详情
  getAttributePolicy: (id) => {
    return request.get(`/api/attribute-policies/${id}`)
  },

  // 更新属性策略
  updateAttributePolicy: (id, policy) => {
    return request.put(`/api/attribute-policies/${id}`, policy)
  },

  // 删除属性策略
  deleteAttributePolicy: (id) => {
    return request.delete(`/api/attribute-policies/${id}`)
  },

  // 获取属性策略列表
  getAttributePolicies: (page = 1, size = 10) => {
    return request.get('/api/attribute-policies', {
      params: { page, size }
    })
  },

  // 获取角色的属性策略
  getAttributePoliciesByRole: (roleId) => {
    return request.get(`/api/attribute-policies/role/${roleId}`)
  },

  // 获取权限的属性策略
  getAttributePoliciesByPermission: (permissionId) => {
    return request.get(`/api/attribute-policies/permission/${permissionId}`)
  },

  // 根据属性查询策略
  getAttributePoliciesByAttribute: (key, value) => {
    return request.get('/api/attribute-policies/attribute', {
      params: { key, value }
    })
  }
} 